package applicationPlugin.Browser;

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.JScrollPane.*;
import javax.swing.border.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;

import interfacesplugins.InterfaceFilesTraitement;
import interfacesplugins.InterfacePlugins;
/**
 * 
 * Classe Plugin lecteur de HTML et HTM Browser
 *
 */
public class Browser extends JFrame implements
		InterfaceFilesTraitement {

	/**
	 * 
	 */
	private boolean etat=true;
	private static final long serialVersionUID = 1L;
	JEditorPane htmlPane;
	String r;
	private File file;

	public Browser() {
		Dimension d=Toolkit.getDefaultToolkit().getScreenSize();
		setBounds((d.width/2)-280, (d.height/2)-350, 750, 500);
		etat=true;
	}

	public void lireHtml(File f) {
		JEditorPane editorPane = new JEditorPane();
    	editorPane.setEditable(false);
		URL helpURL;
		try {
			
			helpURL = f.toURL();
			editorPane.setPage(helpURL);
	        add(editorPane);
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
	        
	
	}	

	@Override
	public String getNomPlugin() {
		// TODO Auto-generated method stub
		return "JTree Web Browser";
	}

	@Override
	public String getVersion() {
		// TODO Auto-generated method stub
		return "1.0";
	}

	@Override
	public String getDeveloppeur() {
		// TODO Auto-generated method stub
		return "Sebastien Lagneau";
	}

	@Override
	public String[] getExtension() {
		// TODO Auto-generated method stub
		String[] s = { "html", "htm" };
		return s;
	}

	@Override
	public JFrame lancerFichier(File f) {
		// TODO Auto-generated method stub
		Browser e = new Browser();
		this.file=f;
		this.etat=true;
		e.lireHtml(f);
		e.setVisible(true);
		e.setTitle("Browser");
		return e;
	}
	
	

	@Override
	public boolean getEtat() {
		// TODO Auto-generated method stub
		return etat;
	}

	@Override
	public boolean setEtat(boolean etat) {
		// TODO Auto-generated method stub
		this.etat=etat;
		return etat;
	}

	@Override
	public ImageIcon getIcon() {
		// TODO Auto-generated method stub
		return new ImageIcon("../Plugins/bin/applicationPlugin/Browser/browser.png");
	}
}
